package org.dftproject.genesis.ui.widgets.gallery;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.FigureCanvas;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.ToolbarLayout;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;

public class Gallery extends FigureCanvas {

	private final IFigure contents;
	
	public static final Color borderColor = new Color(null, 128, 128, 128);
	
	public Gallery(Composite parent) {
		super(parent);
		
		contents = new Figure();
		contents.setOpaque(true);
		contents.setBackgroundColor(ColorConstants.white);
		ToolbarLayout rootLayout = new ToolbarLayout(false);
		rootLayout.setSpacing(5);
		rootLayout.setStretchMinorAxis(true);
		contents.setLayoutManager(rootLayout);
		contents.setBorder(new MarginBorder(5));
		setContents(contents);
	}

	public void addItem(Image image, boolean selected, String tooltipText, Runnable runnable) {
		GalleryButtonFigure button = new GalleryButtonFigure(image, selected, tooltipText, runnable);
		contents.add(button);
	}
	
	public void addItem(IFigure figure, boolean selected, String tooltipText, Runnable runnable) {
		GalleryButtonFigure button = new GalleryButtonFigure(figure, selected, tooltipText, runnable);
		contents.add(button);
	}

}
